package dawnland03.model.team;

import dawnland03.model.utility.Utility;

import java.util.Map;
import java.util.HashMap;

/**
 * User: Petru Obreja (obrejap@yahoo.com)
 * Date: Feb 13, 2010
 * Time: 10:31:33 PM
 */
public class TeamFactory {
    private final static ThreadGroup threadGroup;
    private final static Map<Integer, Team> teams;

     static {
        threadGroup = new ThreadGroup("Teams");
        teams = new HashMap<Integer, Team>();
    }

    public static Team createTeam(String teamName, Integer initialNumberOfTeamMembers){
        Team team = new Team(Utility.getNextUuid(), teamName, initialNumberOfTeamMembers);
        TeamBrain teamBrain = new TeamBrain(team);
        team.setTeamBrain(teamBrain);
        teams.put(team.getId(), team);
        Thread thread = new Thread(threadGroup, teamBrain, "Team "+team.getId());
        thread.start();
        return team;
    }
}
